var http = require('http'),
    url = require("url"),
    path = require("path"),
    fs = require("fs");

http.createServer(function (req, res) {
    debugger;
    var pathname = __dirname + url.parse(req.url).pathname;
    if (path.extname(pathname) == "") {
        pathname += "/";
    }
    if (pathname.charAt(pathname.length - 1) == "/") {
        pathname += "index.html";
    }
    debugger;
    res.writeHead(200, { "Content-Type": "text/html; charset=utf-8"});
    fs.readFile(pathname, function (err, data) {
        res.end(data);
    });
}).listen(8888);